package uk.ac.lkl.takteen.energyapp;

import uk.ac.lkl.takteen.energyapp.data.EnergyAppProvider;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TabHost;

public class Pledges extends TabActivity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.energyapplist_tabs);

		TabHost tabHost = getTabHost();

		TabHost.TabSpec spec; // Resusable TabSpec for each tab
		Intent intent; // Reusable Intent for each tab

		// Create an Intent to launch an Activity for the tab (to be reused)
		intent = new Intent(Intent.ACTION_VIEW,
				EnergyAppProvider.USER_PLEDGES_DIR, Pledges.this,
				ActivePledgesList.class);
		// Initialize a TabSpec for each tab and add it to the TabHost
		spec = tabHost.newTabSpec("active pledges")
				.setIndicator("Your active pledges", null).setContent(intent);
		tabHost.addTab(spec);

		// Do the same for the other tabs
		intent = new Intent(Intent.ACTION_VIEW,
				EnergyAppProvider.USER_PLEDGES_DIR, Pledges.this,
				ExpiredPledgesList.class);
		spec = tabHost.newTabSpec("expired pledges")
				.setIndicator("Your expired pledges", null).setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent(Intent.ACTION_VIEW,
				EnergyAppProvider.SHARED_PLEDGES_DIR, Pledges.this,
				SharedPledgesList.class);
		spec = tabHost.newTabSpec("shared pledges")
				.setIndicator("Pledges shared with you", null)
				.setContent(intent);
		tabHost.addTab(spec);

		if (getIntent().getFlags() == 1)
			tabHost.setCurrentTab(1);
		else if (getIntent().getFlags() == 2)
			tabHost.setCurrentTab(2);
		else
			tabHost.setCurrentTab(0);
	}

}
